import sys

from PySide6.QtWidgets import QApplication,QWidget,QPushButton,QVBoxLayout
from PySide6.QtCore import Qt

class MyWidget(QWidget):
    def __init__(self):
        super().__init__()
        # 布局
        mainlayout = QVBoxLayout()

        btn = QPushButton('控制台打印你好')
        # 添加信号，绑定事件
        btn.clicked.connect(self.hello)
        # 添加到布局中
        mainlayout.addWidget(btn)
        # 设置布局
        self.setLayout(mainlayout)

    def hello(self):
        print('hello world')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MyWidget()
    window.show()
    sys.exit(app.exec())